using System.Collections.Generic;
using Firestarter.DB.Schema.BO;
using Firestarter.DM_DB.Logic;
using FireStarterModeller.BO;
using FireStarterModeller.Test;
using NUnit.Framework;

namespace Firestarter.DB_DM.Logic.Test
{
    [TestFixture]
    public class TestDBFactory_CreateDBKey : TestBase
    {
        [Test]
        public void Test_CreateDBKey()
        {
            //---------------Set up test pack-------------------
            DMClass @class = TestUtilsDMClass.CreateUnsavedValidDMClass();
            DMProperty dmProperty = TestUtilsShared.CreateUnsavedValidDMProperty(@class);
            var properties = new List<DMProperty>();
            properties.Add(dmProperty);
            DMUniqueConstraint uniqueConstraint = @class.CreateUnsavedUniqueConstraint(properties);
            DBFactory factory = TestDBFactory.CreateDBFactory();
            //---------------Execute Test ----------------------
            DBKey dbKey = factory.CreateDBKey(uniqueConstraint, factory.CreateDBTable(@class));
            ////---------------Test Result -----------------------
            Assert.AreEqual(1, dbKey.Columns.Count);
            Assert.AreEqual(dmProperty.MappedDBColumnName, dbKey.Columns[0].ColumnName);
            Assert.AreEqual(uniqueConstraint.UniqueConstraintName, dbKey.KeyName);
        }
    }
}